﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using XYTXL.AppCode;
using XYTXL.Data;
using System.Text;
using System.Data;
using Newtonsoft.Json;
using XYTXL.API;
using NPOI.SS.UserModel;
using System.IO;
using NPOI.XSSF.UserModel;
using NPOI.HSSF.UserModel;

namespace XYTXL.View
{
    /// <summary>
    /// Handler1 的摘要说明
    /// </summary>GetMenuBtData
    public class AdminHandle : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            context.Response.ContentType = "text/plain";
            string strAction = context.Request["Action"].ToString();

            try
            {

                switch (strAction)
                {
                    case "UpdateMM"://获取首页中的菜单index.aspx
                        {
                            string strUserName = HttpContext.Current.Session["UserName"] as string;
                            string strPassword = context.Request.Form["NPASD1"] as string;
                            new JH_Auth_UserB().UpadteMiMa(strUserName, strPassword);
                        }
                        break;
                    case "GetMainMenu"://获取首页中的菜单index.aspx
                        {
                            string strUserName = context.Request.QueryString["UserName"].ToString();
                            string strPMenuCode = context.Request.QueryString["PMenuCode"] ?? "";
                            string strMenu = "";
                            DataTable ListAuth = new JH_Auth_MenuB().GetDTByCommand(" select * from vw_JH_Auth_UserAuth where  UserName='" + strUserName + "'  and isMenu='Y' and IsUse='Y'");
                            strMenu = new JH_Auth_MenuB().GetChiMenuByUserName(strUserName, int.Parse(strPMenuCode), ListAuth);
                            context.Response.Write(strMenu);
                        }
                        break;
                    case "GetMenuBtData"://获取菜单按钮权限
                        {
                            string MenuCode = context.Request.QueryString["MenuCode"] ?? "0";
                            string strUserCode = context.Request["UserCode"] ?? "";
                            DataTable DTAuth = new JH_Auth_MenuB().GetDTByCommand(" select  AuthName from vw_JH_Auth_UserAuth where  UserName='" + strUserCode + "' and PAUTHCODE='" + MenuCode + "'");
                            string strMenu = JsonConvert.SerializeObject(DTAuth);
                            context.Response.Write(strMenu);
                        }
                        break;
                    case "addRole"://添加角色Role.aspx
                        {
                            JH_Auth_Role NewRole = new JH_Auth_Role();
                            NewRole.PRoleCode = 0;
                            NewRole.RoleName = context.Request.QueryString["rolename"].ToString();
                            NewRole.RoleDec = context.Request.QueryString["roledec"].ToString();
                            NewRole.IsUse = context.Request.QueryString["isuse"].ToString();
                            NewRole.isSysRole = "N";
                            new JH_Auth_RoleB().Insert(NewRole);
                            context.Response.Write("success");
                        }
                        break;
                    case "GetRole"://获取所有角色Role.aspx
                        {
                            string strRoleTree = "[" + new JH_Auth_RoleB().GetRoleTree(-1).TrimEnd(',') + "]";
                            context.Response.Write(strRoleTree);
                        }
                        break;
                    case "delRole"://删除角色Role.aspx
                        {
                            int intRoleCode = int.Parse(context.Request.QueryString["delCode"].ToString());
                            new JH_Auth_RoleB().delRole(intRoleCode);
                        }
                        break;


                    case "AddAuth"://添加权限.aspx
                        {
                            StringBuilder strAddAuthTree = new StringBuilder();
                            JH_Auth_Menu NewAuth = new JH_Auth_Menu();
                            NewAuth.PAuthCode = int.Parse(context.Request.QueryString["nodeid"].ToString());
                            NewAuth.DisplayOrder = int.Parse(context.Request.QueryString["nodeorder"].ToString());
                            NewAuth.AuthLevel = int.Parse(context.Request.QueryString["nodelever"].ToString()) + 1;
                            NewAuth.AuthName = context.Request.QueryString["nodename"].ToString();
                            NewAuth.FileName = context.Request.QueryString["nodeurl"].ToString();
                            NewAuth.IsUse = context.Request.QueryString["nodeisuse"].ToString();
                            NewAuth.IsHasbt = context.Request.QueryString["nodeishasbt"].ToString();
                            NewAuth.Ico = context.Request.QueryString["nodeico"].ToString();
                            NewAuth.isMenu = "Y";
                            NewAuth.isSys = "N";
                            NewAuth.AuthDesc = "";
                            new JH_Auth_MenuB().Insert(NewAuth);
                            if (NewAuth.FileName != "" && NewAuth.IsHasbt == "Y")
                            {
                                new JH_Auth_MenuB().addDefaultBtn(NewAuth);
                            }

                            strAddAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',ishasbt:'{6}',icon:'{7}'}}", NewAuth.AuthCode, NewAuth.PAuthCode, NewAuth.AuthLevel, NewAuth.AuthName, NewAuth.FileName, NewAuth.IsUse, NewAuth.IsHasbt, NewAuth.Ico);
                            context.Response.Write("[" + strAddAuthTree + "]");

                        }
                        break;
                    case "UpdateAuth"://
                        {
                            int nodeid = int.Parse(context.Request.QueryString["nodeid"].ToString());
                            StringBuilder strUpAuthTree = new StringBuilder();
                            JH_Auth_Menu UpAuth = new JH_Auth_MenuB().GetEntities(d => d.AuthCode == nodeid).SingleOrDefault();
                            UpAuth.AuthName = context.Request.QueryString["nodename"].ToString();
                            UpAuth.DisplayOrder = int.Parse(context.Request.QueryString["nodeorder"].ToString());
                            UpAuth.FileName = context.Request.QueryString["nodeurl"].ToString();
                            UpAuth.IsUse = context.Request.QueryString["nodeisuse"].ToString();
                            UpAuth.IsHasbt = context.Request.QueryString["nodeishasbt"].ToString();

                            UpAuth.Ico = context.Request.QueryString["nodeico"].ToString();
                            new JH_Auth_MenuB().Update(UpAuth);
                            strUpAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',ishasbt:'{6}',icon:'{7}',order:'{8}'}}", UpAuth.AuthCode, UpAuth.PAuthCode, UpAuth.AuthLevel, UpAuth.AuthName, UpAuth.FileName, UpAuth.IsUse, UpAuth.IsHasbt, UpAuth.Ico, UpAuth.DisplayOrder);
                            context.Response.Write("[" + strUpAuthTree + "]");
                        }
                        break;

                    case "updateRole"://修改角色Role.aspx
                        {
                            int nodeid = int.Parse(context.Request.QueryString["rolecode"].ToString());

                            JH_Auth_Role UPRole = new JH_Auth_RoleB().GetEntities(d => d.RoleCode == nodeid).SingleOrDefault();
                            UPRole.RoleName = context.Request.QueryString["rolename"].ToString();
                            UPRole.RoleDec = context.Request.QueryString["roledec"].ToString();
                            UPRole.IsUse = context.Request.QueryString["isuse"].ToString();
                            new JH_Auth_RoleB().Update(UPRole);
                            context.Response.Write("[success]");
                        }
                        break;
                    case "GetRoleMenu"://设置角色权限assginRole.aspx
                        {
                            int RoleCode = int.Parse(context.Request.QueryString["RoleCode"].ToString());
                            List<JH_Auth_Menu> ListAuth = new JH_Auth_MenuB().GetEntities(d => d.IsUse == "Y").ToList();
                            List<JH_Auth_RoleAuth> ListAuth_Role = new JH_Auth_RoleAuthB().GetEntities(rm => rm.RoleCode == RoleCode).ToList();

                            string strMenu = "[" + new JH_Auth_RoleAuthB().GetRoleAuth(RoleCode, -1, ListAuth, ListAuth_Role).TrimEnd(',') + "]";
                            context.Response.Write(strMenu);
                        }
                        break;
                    case "GetBranchUser"://获取所有机构用户AssignUser.aspx
                        {
                            string strChecks = context.Request["CheckNodes"] ?? "";
                            string strUserTree = "[" + new JH_Auth_BranchB().GetBranchUserTree(strChecks, -1).TrimEnd(',') + "]";
                            context.Response.Write(strUserTree);
                        }
                        break;
                    case "GetAllAuth"://MenuList.aspx
                        {
                            string strAuth = "[" + new JH_Auth_MenuB().GetAllAuth(-1).TrimEnd(',') + "]";
                            context.Response.Write(strAuth);
                        }
                        break;
                    case "GetBranch"://获取所有机构BranchList.aspx
                        {
                            string strBranchTree = "[" + new JH_Auth_BranchB().GetBranchTree(-1).TrimEnd(',') + "]";
                            context.Response.Write(strBranchTree);
                        }
                        break;
                    case "delBranch"://获取所有用户UserList.aspx
                        {
                            int intBranchCode = int.Parse(context.Request.QueryString["delCode"].ToString());
                            if (new JH_Auth_UserB().GetEntities(D => D.BranchCode == intBranchCode).Count() > 0)
                            {
                                context.Response.Write("不能删除带用户的部门");
                            }
                            else
                            {
                                new JH_Auth_BranchB().DelBranchByCode(intBranchCode);

                                context.Response.Write("success");
                            }

                        }
                        break;
                    case "delUser"://删除用户
                        {
                            string strUserName = context.Request.QueryString["delCode"].ToString();
                            new JH_Auth_UserB().Delete(d => d.UserName == strUserName);
                             
                        }
                        break;
                    case "DelMenu"://删除菜单
                        {
                            int MenuID = int.Parse(context.Request.QueryString["MenuID"].ToString());
                            if (new JH_Auth_MenuB().DelAllMenuByID(MenuID))
                            {
                                context.Response.Write("success");
                            }
                            else
                            {
                                context.Response.Write("error");
                            }
                        }
                        break;

                    case "GetBJ"://设置角色权限assginRole.aspx
                        {
                            string bjs = context.Request["bjs"].ToString();
                            string strMenu = "[" + new xy_bjB().GetNJBN(bjs).TrimEnd(',') + "]";
                            context.Response.Write(strMenu);
                        }
                        break;
                    case "ImportUser"://删除菜单
                        {
                            try
                            {
                                HttpPostedFile _upfile = context.Request.Files["upFile"];
                                if (_upfile == null)
                                {
                                    context.Response.Write("无文件");
                                }
                                else
                                {
                                    string fileName = _upfile.FileName;/*获取文件名： C:\Documents and Settings\Administrator\桌面\123.jpg*/
                                    string suffix = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();/*获取后缀名并转为小写： jpg*/
                                    int bytes = _upfile.ContentLength;//获取文件的字节大小   
                                    if (suffix == "xls" || suffix == "xlsx")
                                    {
                                        IWorkbook workbook = null;

                                        Stream stream = _upfile.InputStream;

                                        if (suffix == "xlsx") // 2007版本
                                        {
                                            workbook = new XSSFWorkbook(stream);
                                        }
                                        else if (suffix == "xls") // 2003版本
                                        {
                                            workbook = new HSSFWorkbook(stream);
                                        }

                                        //获取excel的第一个sheet
                                        ISheet sheet = workbook.GetSheetAt(0);

                                        //获取sheet的第一行
                                        IRow headerRow = sheet.GetRow(0);

                                        //一行最后一个方格的编号 即总的列数
                                        int cellCount = headerRow.LastCellNum;
                                        //最后一列的标号  即总的行数
                                        int rowCount = sheet.LastRowNum;
                                        if (rowCount <= 0)
                                        {
                                            context.Response.Write("文件无数据");
                                        }
                                        else
                                        {

                                            for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
                                            {
                                                IRow row = sheet.GetRow(i);
                                                string strName = row.GetCell(0) != null ? row.GetCell(0).ToString().Trim() : "";
                                                string strBR = row.GetCell(1) != null ? row.GetCell(1).ToString().Trim() : "";
                                                string strRName = row.GetCell(2) != null ? row.GetCell(2).ToString().Trim() : "";

                                                if (strName != "" && strBR != "")
                                                {
                                                    var user = new JH_Auth_UserB().GetEntities(" UserName=N'" + strName + "'").FirstOrDefault();
                                                    if (user == null)
                                                    {
                                                        JH_Auth_User NewUser = new JH_Auth_User();
                                                        NewUser.UserName = strName;
                                                        NewUser.UserRealName = strRName;
                                                        NewUser.UserPass = "123";
                                                        NewUser.IsUse = "Y";
                                                        NewUser.tx = "TX10";
                                                        NewUser.STATUS = "";

                                                        var br = new JH_Auth_BranchB().GetEntities(" DeptName=N'" + strBR + "'").FirstOrDefault();
                                                        if (br != null)
                                                        {
                                                            NewUser.BranchCode = br.DeptCode;
                                                            NewUser.remark = new JH_Auth_BranchB().GetEntity(d => d.DeptCode == NewUser.BranchCode).Remark1;
                                                        }
                                                        else
                                                        {
                                                            JH_Auth_Branch NewBranch = new JH_Auth_Branch();
                                                            NewBranch.DeptName = strBR;
                                                            NewBranch.DeptRoot = 1;
                                                            NewBranch.DeptShort = new JH_Auth_BranchB().GetEntities(d => d.DeptRoot == 1).Max(d => d.DeptShort) + 1;
                                                            NewBranch.DeptDesc = "";
                                                            NewBranch.BranchLevel = 0;

                                                            JH_Auth_Branch BranchUP = new JH_Auth_BranchB().GetEntities("DeptCode='1' ").SingleOrDefault();
                                                            if (BranchUP != null)
                                                            {
                                                                int number = 0;
                                                                List<JH_Auth_Branch> branchList = new JH_Auth_BranchB().GetEntities(" DeptRoot='1'").OrderBy(d => d.DeptCode).ToList<JH_Auth_Branch>();
                                                                if (branchList.Count > 0)
                                                                {
                                                                    string code = branchList.LastOrDefault().Remark1;
                                                                    int.TryParse(code, out number);
                                                                    NewBranch.Remark1 = (number + 1).ToString();
                                                                }
                                                                else
                                                                {
                                                                    NewBranch.Remark1 = (1 + "1").ToString();
                                                                }
                                                            }
                                                            else
                                                            {
                                                                int number = 0;
                                                                int.TryParse(new JH_Auth_BranchB().GetEntities(d => d.DeptRoot == BranchUP.DeptRoot).OrderBy(d => d.DeptCode).LastOrDefault().Remark1, out number);
                                                                NewBranch.Remark1 = (number + 1).ToString();
                                                            }
                                                            new JH_Auth_BranchB().Insert(NewBranch);

                                                            NewUser.BranchCode = NewBranch.DeptCode;
                                                            NewUser.remark = NewBranch.Remark1;
                                                            
                                                        }
                                                        new JH_Auth_UserB().Insert(NewUser);
                                                        new JH_Auth_UserRoleB().Insert(new JH_Auth_UserRole() { RoleCode = 3, UserName = NewUser.UserName });
                                                    }
                                                }
                                            }
                                        }

                                        sheet = null;
                                        workbook = null;
                                        context.Response.Write("success");
                                    }
                                    else
                                    {
                                        context.Response.Write("请上传excel文件");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                context.Response.Write("error");
                            }
                        }
                        break;


                    default:
                        break;
                }
            }
            catch (Exception ex)
            {

                context.Response.Write("error");
            }
            ////Branch.aspx
            ////获取所有机构
            //if (strAction == "GetBranch")
            //{
            //    string strUserTree = "[" + new CommonHelp.Account().GetBranchTree(-1).TrimEnd(',') + "]";
            //    context.Response.Write(strUserTree);
            //}

            //if (strAction == "GetAllAuth")
            //{
            //    string strAuth = "[" + new CommonHelp.Account().GetAllAuth(-1).TrimEnd(',') + "]";
            //    context.Response.Write(strAuth);
            //}




            ////删除机构Branch.aspx
            //if (strAction == "delBranch")
            //{
            //    int intBranchCode = int.Parse(context.Request.QueryString["delCode"].ToString());
            //    new CommonHelp.Account().DelBranchByCode(intBranchCode);
            //}
            ////删除用户Branch.aspx
            //if (strAction == "delUser")
            //{
            //    string strUserName = context.Request.QueryString["delCode"].ToString();
            //    new CommonHelp.Account().DelUserByCode(strUserName);
            //}

            ////Menu.aspx
            ////获取菜单管理页面所有菜单Menu.aspx
            //if (strAction == "GetAllAuth")
            //{
            //    string strAuth = "[" + new CommonHelp.Account().GetAllAuth(-1).TrimEnd(',') + "]";
            //    context.Response.Write(strAuth);
            //}
            ////增加菜单Menu.aspx
            //if (strAction == "AddAuth")
            //{
            //    StringBuilder strAddAuthTree = new StringBuilder();
            //    JH_Auth_Menu NewAuth = new JH_Auth_Menu();
            //    NewAuth.PAuthCode = int.Parse(context.Request.QueryString["nodeid"].ToString());
            //    NewAuth.DisplayOrder = int.Parse(context.Request.QueryString["nodeorder"].ToString());
            //    NewAuth.AuthLevel = int.Parse(context.Request.QueryString["nodelever"].ToString()) + 1;
            //    NewAuth.AuthName = context.Request.QueryString["nodename"].ToString();
            //    NewAuth.FileName = context.Request.QueryString["nodeurl"].ToString();
            //    NewAuth.IsUse = context.Request.QueryString["nodeisuse"].ToString();
            //    NewAuth.Ico = context.Request.QueryString["nodeico"].ToString();
            //    NewAuth.isMenu = "Y";
            //    NewAuth.isSys = "N";
            //    NewAuth.AuthDesc = "";
            //    new JH_Auth_MenuB().Insert(NewAuth);
            //    strAddAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',icon:'{6}'}}", NewAuth.AuthCode, NewAuth.PAuthCode, NewAuth.AuthLevel, NewAuth.AuthName, NewAuth.FileName, NewAuth.IsUse, NewAuth.Ico);
            //    context.Response.Write("[" + strAddAuthTree + "]");

            //}
            ////添加菜单下的按钮Menu.aspx
            //if (strAction == "AddMenuButton")
            //{
            //    StringBuilder strAddAuthTree = new StringBuilder();
            //    JH_Auth_Menu NewAuth = new JH_Auth_Menu();
            //    NewAuth.PAuthCode = int.Parse(context.Request.QueryString["MenuID"].ToString());
            //    NewAuth.AuthLevel = int.Parse(context.Request.QueryString["nodelever"].ToString()) + 1;
            //    NewAuth.AuthName = context.Request.QueryString["btndec"].ToString();
            //    NewAuth.FileName = context.Request.QueryString["btnid"].ToString();
            //    NewAuth.IsUse = "Y";
            //    NewAuth.Ico = "";
            //    NewAuth.isMenu = "N";
            //    NewAuth.isSys = "N";
            //    NewAuth.AuthDesc = "";
            //    new JH_Auth_MenuB().Insert(NewAuth);
            //    strAddAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',icon:'{6}'}}", NewAuth.AuthCode, NewAuth.PAuthCode, NewAuth.AuthLevel, NewAuth.AuthName, NewAuth.FileName, NewAuth.IsUse, NewAuth.Ico);
            //    context.Response.Write("[" + strAddAuthTree + "]");

            //}
            ////修改菜单Menu.aspx
            //if (strAction == "UpdateAuth")
            //{
            //    int nodeid = int.Parse(context.Request.QueryString["nodeid"].ToString());
            //    StringBuilder strUpAuthTree = new StringBuilder();
            //    JH_Auth_Menu UpAuth = new JH_Auth_MenuB().GetEntities(d => d.AuthCode == nodeid).SingleOrDefault();
            //    UpAuth.AuthName = context.Request.QueryString["nodename"].ToString();
            //    UpAuth.DisplayOrder = int.Parse(context.Request.QueryString["nodeorder"].ToString());
            //    UpAuth.FileName = context.Request.QueryString["nodeurl"].ToString();
            //    UpAuth.IsUse = context.Request.QueryString["nodeisuse"].ToString();
            //    UpAuth.Ico = context.Request.QueryString["nodeico"].ToString();
            //    new JH_Auth_MenuB().Update(UpAuth);
            //    strUpAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',icon:'{6}',order:'{7}'}}", UpAuth.AuthCode, UpAuth.PAuthCode, UpAuth.AuthLevel, UpAuth.AuthName, UpAuth.FileName, UpAuth.IsUse, UpAuth.Ico, UpAuth.DisplayOrder);
            //    context.Response.Write("[" + strUpAuthTree + "]");
            //}
            ////修改菜单Menu.aspx
            //if (strAction == "UpdateMenuBtn")
            //{

            //    int nodeid = int.Parse(context.Request.QueryString["btncode"].ToString());
            //    StringBuilder strUpAuthTree = new StringBuilder();
            //    JH_Auth_Menu UpAuth = new JH_Auth_MenuB().GetEntities(d => d.AuthCode == nodeid).SingleOrDefault();
            //    UpAuth.AuthName = context.Request.QueryString["btndec"].ToString();
            //    UpAuth.FileName = context.Request.QueryString["btnid"].ToString();
            //    new JH_Auth_MenuB().Update(UpAuth);
            //    strUpAuthTree.AppendFormat("{{id:'{0}',pId:'{1}',level:'{2}',name:'{3}',taburl:'{4}',isuse:'{5}',icon:'{6}',order:'{7}'}}", UpAuth.AuthCode, UpAuth.PAuthCode, UpAuth.AuthLevel, UpAuth.AuthName, UpAuth.FileName, UpAuth.IsUse, UpAuth.Ico, UpAuth.DisplayOrder);
            //    context.Response.Write("[" + strUpAuthTree + "]");
            //}
            ////删除菜单Menu.aspx
            //if (strAction == "delAuth")
            //{
            //    int intAuthCode = int.Parse(context.Request.QueryString["delCode"].ToString());

            //    new CommonHelp.Account().DelAuthCode(intAuthCode);
            //}

            ////Role.aspx
            ////获取所有角色Role.aspx
            //if (strAction == "GetRole")
            //{
            //    string strRoleTree = "[" + new CommonHelp.Account().GetRoleTree(-1).TrimEnd(',') + "]";
            //    context.Response.Write(strRoleTree);
            //}
            ////删除角色Role.aspx
            //if (strAction == "delRole")
            //{
            //    int intRoleCode = int.Parse(context.Request.QueryString["delCode"].ToString());
            //    new CommonHelp.Account().delRole(intRoleCode);
            //}
            ////添加角色Role.aspx
            //if (strAction == "addRole")
            //{
            //    JH_Auth_Role NewRole = new JH_Auth_Role();
            //    NewRole.PRoleCode = 0;
            //    NewRole.RoleName = context.Request.QueryString["rolename"].ToString();
            //    NewRole.RoleDec = context.Request.QueryString["roledec"].ToString();
            //    NewRole.isSysRole = context.Request.QueryString["issys"].ToString();
            //    NewRole.IsUse = context.Request.QueryString["isuse"].ToString();
            //    new JH_Auth_RoleB().Insert(NewRole);
            //    context.Response.Write("success");
            //}

            ////修改角色Role.aspx
            //if (strAction == "updateRole")
            //{
            //    int nodeid = int.Parse(context.Request.QueryString["rolecode"].ToString());

            //    JH_Auth_Role UPRole = new JH_Auth_RoleB().GetEntities(d => d.RoleCode == nodeid).SingleOrDefault();
            //    UPRole.RoleName = context.Request.QueryString["rolename"].ToString();
            //    UPRole.RoleDec = context.Request.QueryString["roledec"].ToString();
            //    UPRole.isSysRole = context.Request.QueryString["issys"].ToString();
            //    UPRole.IsUse = context.Request.QueryString["isuse"].ToString();
            //    new JH_Auth_RoleB().Update(UPRole);
            //    context.Response.Write("[success]");
            //}

            ////设置角色权限assginRole.aspx
            //if (strAction == "GetRoleMenu")
            //{
            //    int RoleCode = int.Parse(context.Request.QueryString["RoleCode"].ToString());
            //    string strMenu = "[" + new CommonHelp.Account().GetRoleAuth(RoleCode, -1).TrimEnd(',') + "]";
            //    context.Response.Write(strMenu);
            //}

            ////AssignUser.ASPX
            ////获取所有机构用户
            //if (strAction == "GetBranchUser")
            //{
            //    int RoleCode = int.Parse(context.Request.QueryString["RoleCode"].ToString());
            //    string strUserTree = "[" + new CommonHelp.Account().GetBranchUserTree(RoleCode, -1).TrimEnd(',') + "]";
            //    context.Response.Write(strUserTree);

            //}

            ////删除用户角色关系
            //if (strAction == "DelUserRole")
            //{
            //    int RoleCode = int.Parse(context.Request.QueryString["rolecode"].ToString());

            //    string UserName = context.Request.QueryString["username"].ToString();
            //    new CommonHelp.Account().DelUserRole(UserName, RoleCode);
            //}

            //if (strAction == "addBranch")
            //{
            //    JH_Auth_Branch NewBranch = new JH_Auth_Branch();
            //    NewBranch.DeptName = context.Request.QueryString["BranchName"].ToString();
            //    NewBranch.DeptRoot = int.Parse(context.Request.QueryString["PBranchCode"].ToString());
            //    NewBranch.Remark1 = context.Request.QueryString["ChargePeople"].ToString();
            //    NewBranch.DeptDesc = NewBranch.DeptName;
            //    NewBranch.BranchLevel = 0;
            //    NewBranch.DeptShort = 0;
            //    new JH_Auth_BranchB().Insert(NewBranch);
            //    context.Response.Write(NewBranch.DeptCode);
            //}

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}